package Ventanas;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Juegos.Juego;







public class Principal extends javax.swing.JFrame {
	private JPanel jPanel1;
	private JButton jButton1;
	private JButton jButton4;
	private JButton jButton3;
	private JLabel jLabel3;
	private JLabel jLabel2;
	private JLabel jLabel1;
	private JButton jButton2;
	private JOptionPane pan;
	
	private Mapas map;
private Juego juego;
	/**
	*constructor de inicializacion del juego
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				Principal inst = new Principal();
				inst.setMinimumSize(new Dimension(400,300));
				inst.setVisible(true);
				
				
				
			}
		});
	}
	
	public Principal() {
		super();
		initGUI();
			map= new Mapas();
	
	}
	
	private void initGUI() {
		try {
			setTitle("Super Mario Bros");
			
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setLayout(null);
				jPanel1.setBackground(new java.awt.Color(0,0,160));
				jPanel1.setPreferredSize(new java.awt.Dimension(507, 434));
				jPanel1.setSize(600, 500);
				jPanel1.setMaximumSize(new java.awt.Dimension(600, 600));


				{
					jButton1 = new JButton();
					jPanel1.add(jButton1);
					jButton1.setBounds(24, 314, 110, 97);
					jButton1.setIcon(new ImageIcon(getClass().getClassLoader().getResource("GraficosVentana/mariobonus.gif")));
					jButton1.addActionListener(new MiOyente2());


				}
				{
					jButton2 = new JButton();
					jPanel1.add(jButton2);
					jButton2.setBounds(158, 314, 110, 97);
					jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource("GraficosVentana/luigibonus.gif")));
					jButton2.addActionListener(new MiOyente1());


				}
				{
					jLabel1 = new JLabel();
					
					jLabel1.setIcon(new ImageIcon(getClass().getClassLoader().getResource("GraficosVentana/super.GIF")));
					jPanel1.add(jLabel1);
					jLabel1.setBounds(37, 1, 282, 150);


				}
				{
					jLabel2 = new JLabel();
					jPanel1.add(jLabel2);
					jLabel2.setIcon(new ImageIcon(getClass().getClassLoader().getResource("GraficosVentana/marioB.GIF")));
				jLabel2.setBounds(102, 100, 413, 154);


				}
				{
					jLabel3 = new JLabel();
					jPanel1.add(jLabel3);
					jLabel3.setText("Seleccione el personaje para jugar:");
					jLabel3.setBounds(12, 282, 190, 14);
					jLabel3.setFont(new java.awt.Font("Arial",3,10));
					jLabel3.setForeground(new java.awt.Color(255,255,255));


				}
				{
					jButton3 = new JButton();
					jPanel1.add(jButton3);
					jButton3.setBounds(313, 380, 175, 31);
					jButton3.setText("Controles");
					jButton3.setFont(new java.awt.Font("Baskerville Old Face",1,14));
					jButton3.addActionListener(new MiOyente());


				}
				{
					jButton4 = new JButton();
					jPanel1.add(jButton4);
					jButton4.setText("Mapas");
						jButton4.setFont(new java.awt.Font("Baskerville Old Face",1,14));
					jButton4.setBounds(313, 331, 174, 31);
					jButton4.addActionListener(new MiOyente4());


				}
			}
			pack();
			this.setBounds(0, 0, 513, 478);
			this.setSize(513, 478);
			this.setResizable(false);


		} catch (Exception e) {
		   
			e.printStackTrace();
		}
		
	
	}
	class MiOyente implements ActionListener{
		 public void actionPerformed(ActionEvent e)
		 {
		 Controles c= new Controles();
	      c.setVisible(true);
	      c.setLocationRelativeTo(null);
	    }
}
	class MiOyente1 implements ActionListener{
		 public void actionPerformed(ActionEvent e)
		 {
			
			juego = new Juego(1,map.obtenerNivel());
				juego.setLocationRelativeTo(null);
				juego.setVisible(true);
		    }
	    }

	class MiOyente2 implements ActionListener{
		 public void actionPerformed(ActionEvent e)
		 
		 {
	       
		juego = new Juego(0,map.obtenerNivel());
			juego.setLocationRelativeTo(null);
			juego.setVisible(true);
	    }
}
	class MiOyente4 implements ActionListener{
		 public void actionPerformed(ActionEvent e)
		 {
			    
			map = new Mapas();
				map.setLocationRelativeTo(null);
				map.setVisible(true);
	
		
		    }
	    }
}

